import { areaList } from '@vant/area-data';

Page({
    data: {
        userInfo: {},
        // 被收藏的商品的数量
        collectNums: 0,
        hasLogin: false,
        data: [],
        areaList
    },
    onShow() {
        let token = wx.getStorageSync('token')
        let that = this
        wx.request({

            url: "https://www.cbing.icu:8095/wxUser/getAddress",
            method: 'GET',
            header: {
                'Authorization': token
            },
            success(res) {
                console.log(res.data.data)
                that.setData({
                    data: res.data.data
                })
            }
        })
    },
    select(e) {
        let index = e.currentTarget.dataset.index
        wx.setStorageSync('addIndex',index)
        wx.navigateBack({
            delta:1
        })
    },
    addAddress() {
        wx.navigateTo({
            url: '../addAddress/index'
        })
    },
    change(e) {
        let index = e.currentTarget.dataset.index
        let that = this
        wx.navigateTo({
            url: '../changeAddress/index',
            success: (res) => {
                // 通过 eventChannel 向被打开页面传送数据
                res.eventChannel.emit('changeData', {data: that.data.data[index]})
            }
        })
    }
})